<?php
namespace Common\Model;

use Think\Model;

class SystemHooksModel extends \BaseModel
{

    /**
     * 字典
     * @param  integer dict
     * @return string
     */
    public function load($name)
    {
        if (intval($name) > 0) {
            $where = array('id' => $name);
        } else {
            $where = array('hook_name' => $name);
        }
        $data = $this->where($where)->find();
        if ($data) {
            $data['info'] = (array)unserialize($data['info']);
        }
        return $data;
    }


    public function get_hooks($name)
    {
        $data = $this->load($name);
        if (!$data['status'] == 1) {
            return false;
        }
        $hooks = array();
        foreach ($data['info'] as $one) {
            if ($one['enable'] == 1 && $one['name']) {
                $hooks[$one['name']] = $one['name'];
            }
        }
        $hooks[$name] = $name;
        return $hooks;
    }


}
 